import { createRouter, createWebHashHistory,createWebHistory  } from "vue-router";
import Layout from "../views/layout/index.vue";
// import Home from "../views/home/index.vue";
const routes = [
  {
    path: "/",
    name: "Index",
    component: Layout,
    children: [
      {
        path: "/",
        name: "HomeIndex",
        meta: {
          name: "首页"
        },
        component: () => import("../views/home/index.vue"),
      },
      {
        path: "/love",
        name: "Love",
        meta: {
          name: "爱情买卖"
        },
        component: () => import("../views/love/index.vue"),
      },
      {
        path: "/travel",
        name: "Travel",
        meta: {
          name: "旅拍"
        },
        component: () => import("../views/travel/index.vue"),
      },
      {
        path: "/favorite",
        name: "Favorite",
        meta: {
          name: "百宝箱"
        },
        component: () => import("../views/favorite/index.vue"),
      },
      {
        path: "/funny",
        name: "Funny",
        meta: {
          name: "曲乐"
        },
        component: () => import("../views/funny/index.vue"),
      },
      {
        path: "/message",
        name: "Message",
        meta: {
          name: "留言"
        },
        component: () => import("../views/message/index.vue"),
      },
      {
        path: "/friend",
        name: "Friend",
        meta: {
          name: "友人帐"
        },
        component: () => import("../views/friend/index.vue"),
      },
      // {
      //   path: "/gis",
      //   name: "Gis",
      //   meta: {
      //     name: "GIS"
      //   },
      //   component: () => import("../views/cesium/index.vue"),
      // },
      {
        path: "/about",
        name: "About",
        meta: {
          name: "关于"
        },
        component: () => import("../views/about/index.vue"),
      },
      {
        path: "/login",
        name: "Login",
        meta: {
          name: "登录"
        },
        component: () => import("../views/login/index.vue"),
      },
      {
        path: "/user",
        name: "User",
        meta: {
          name: "登录"
        },
        component: () => import("../views/user/index.vue"),
      },
    ]
  },
  {
    path: '/admin',
    meta: {
      title: '欢迎页'
    },
    // redirect: '/welcome',
    // meta: { requiresAuth: true },
    component: () => import('../components/admin/admin.vue'),
    children: [{
      path: '/welcome',
      meta: {
        title: '欢迎页'
      },
      name: 'welcome',
      component: () => import('../components/admin/welcome.vue')
    },
   ]
  },
  {
    path: '/verify',
    name: 'verify',
    component: () => import('../components/admin/verify')
  }
];

const router = createRouter({
  // history: createWebHashHistory(),
  history:createWebHistory(),
  routes,
});


// router.beforeEach((to, from, next) => {
//   if (to.matched.some(record => record.meta.requiresAuth)) {
//     if (!Boolean(localStorage.getItem("adminToken"))) {
//       next({
//         path: '/verify',
//         query: {redirect: to.fullPath}
//       });
//     } else {
//       next();
//     }
//   } else {
//     next();
//   }
// })
export default router;
